function x_est = vblast_detector(y, H, SNR)
    % 获取系统大小
    [Nr, Nt] = size(H);
    
    % 初始化
    x_est = zeros(Nt, 1);
    H_temp = H;
    y_temp = y;
    detect_order = zeros(Nt, 1);
    noise_var = 10^(-SNR/10);
    
    % 逐层检测
    for i = 1:Nt
        % 计算伪逆矩阵
        W = H_temp' * inv(H_temp*H_temp' + noise_var*eye(size(H_temp, 1)));
        
        % 找出最佳检测顺序
        norms = sum(abs(W).^2, 2);
        [~, min_idx] = min(norms);
        detect_order(i) = min_idx;
        
        % 检测符号
        x_est(detect_order(i)) = W(min_idx, :) * y_temp;
        
        % 硬判决
        x_est(detect_order(i)) = sign(real(x_est(detect_order(i)))) + ...
                                1j*sign(imag(x_est(detect_order(i))));
        
        % 消除已检测层的干扰
        y_temp = y_temp - H_temp(:, min_idx) * x_est(detect_order(i));
        H_temp(:, min_idx) = [];
    end
end 